{template 'Public/head2'}
<div class="p-3 bg-light wap">
  <div class="container py-3 mt-3">
    <div class="row">
        <div class="col-7">
            <img src="{$_W['fans']['avatar']}" alt="avatar" class="avatar vam mr-2 fl">
            <span class="fl">
                <p style="font-size:0.34rem;">{$_W['fans']['nickname']}</p>
                <p style="font-size:0.19rem;">{if $_W['fans']['mobile']}{php echo substr($_W['fans']['mobile'],0,3)}****{php echo substr($_W['fans']['mobile'],-4)}{else}****{/if}</p>
                <p class="fc-golden textone" style="font-size:0.24rem;width:2.5rem;">累计充值￥{$_W['fans']['credit1']}</p>
            </span>
        </div>
        <div class="col-5">
            <span class="btn btn-golden fr mt-3">&nbsp;{$level['name']}&nbsp;</span>
        </div>
    </div>
  </div>

  <div class="card br-10" style="height:1.3rem;margin-bottom:0.5rem;">
    <div class="circle1"></div>
    <div class="circle2"></div>
    <div class="content tac">
        <p style="line-height:1.3rem;font-size:0.3rem;">
          <strong>剩余次数：{php echo $_W['fans']['nums']-$_W['fans']['numing']+$_W['fans']['num']}</strong>
        </p>
    </div>
  </div>

  <p class="fs-25 fc-red tac mb-3 bg-white py-2 br-10">
    {if $level['price']>0 && $level['num']>0}
    {$level['price']}元 / {$level['num']}次
    {elseif $level['price']>0}
    {$level['price']}元 / {php echo intval(($_W['sysset']['recharge']['basenum']*$level['price'])/($level['discount']/100));}次
    {else}
    1元 / {php echo intval($_W['sysset']['recharge']['basenum']/($level['discount']/100));}次
    {/if}
  </p>
  {if $level['price']==0}
  <div class="row form-box" style="font-size:0.26rem;line-height:2em;">
      <div class="col-3"><span class="fc-red">*</span> 充值金额</div>
      <div class="col-9">
          <input type="number" name="price" id="price" value="" class="form-input-bg" placeholder="请填写充值金额">
      </div>
      <div style="margin-bottom:0.3rem;clear:both;"></div>
  </div>

  <div class="row" style="font-size:0.28rem;">
    {loop $prices $idx $price}
    <div class="col-3">
      <div class="bg-white br-10 tac py-2 mb-2 price" data-price="{$price}">
        ￥{$price}
      </div>
    </div>
    {/loop}
    <div style="margin-bottom:0.3rem;clear:both;"></div>
  </div>
  {else}
  <input type="hidden" name="price" id="price" value="{$level['price']}">
  {/if}

  <div class="row">
    <div class="col-12">
      <button type="button" id="pay" class="btn btn-block btn-default">确认充值</button>
    </div>
  </div>
</div>
<script>
  $(function(){
    $('.price').on('click', function(){
      $('#price').val($(this).data('price'));
    });
    var is_submit = true;
    $('#pay').on('click', function(){
      if(is_submit){
        is_submit = false;
        $.post("{$_W['baseurl']}&r=merch.createlog", {'price':$('#price').val()}, function(res){
          if(res && res.code==0){
            window.location.href = "{:mobileUrl('',array('do'=>'pay'));}?id="+res.data;
          }else{
            alert('提交失败！');
          }
          is_submit = true;
        });
      }
    });
  });
</script>
{template 'Public/footer'}